import { Byte } from '../../api/io/Byte';
import { HashMap } from '../../api/struct/HashMap';


export const enum E_CDArenaRule {
	/**编号*/
	id,
	/**排名范围<*/
	score,
	/**排名取值范围*/
	rankRange1,
	/**取值范围*/
	rankRange2,
	/**取值范围*/
	rankRange3,
	/**取值范围*/
	rankRange4,
	/**取值范围*/
	rankRange5,
	/**取值范围*/
	rankRange6,
	/**取值范围*/
	rankRange7,
	/**取值范围*/
	rankRange8,
	/**取值范围*/
	rankRange9,
	/**取值范围*/
	rankRange10,

	/**枚举数量*/
	EnumCount
}



export class CDArenaRule{
	/**编号*/
	public id: number;
	/**排名范围<*/
	public score: number;
	/**排名取值范围*/
	public rankRange1: number;
	/**取值范围*/
	public rankRange2: number;
	/**取值范围*/
	public rankRange3: number;
	/**取值范围*/
	public rankRange4: number;
	/**取值范围*/
	public rankRange5: number;
	/**取值范围*/
	public rankRange6: number;
	/**取值范围*/
	public rankRange7: number;
	/**取值范围*/
	public rankRange8: number;
	/**取值范围*/
	public rankRange9: number;
	/**取值范围*/
	public rankRange10: number;


	/**获取属性值*/
	public getAttr(idx: number): any {
		switch(idx) { 
			default: return;
			case E_CDArenaRule.id: return this.id;
			case E_CDArenaRule.score: return this.score;
			case E_CDArenaRule.rankRange1: return this.rankRange1;
			case E_CDArenaRule.rankRange2: return this.rankRange2;
			case E_CDArenaRule.rankRange3: return this.rankRange3;
			case E_CDArenaRule.rankRange4: return this.rankRange4;
			case E_CDArenaRule.rankRange5: return this.rankRange5;
			case E_CDArenaRule.rankRange6: return this.rankRange6;
			case E_CDArenaRule.rankRange7: return this.rankRange7;
			case E_CDArenaRule.rankRange8: return this.rankRange8;
			case E_CDArenaRule.rankRange9: return this.rankRange9;
			case E_CDArenaRule.rankRange10: return this.rankRange10;
		}
	}



	/**设置属性值*/
	public setAttr(idx: number, v: any): void {
		switch(idx) { 
			default: break;
			case E_CDArenaRule.id: this.id = v; break;
			case E_CDArenaRule.score: this.score = v; break;
			case E_CDArenaRule.rankRange1: this.rankRange1 = v; break;
			case E_CDArenaRule.rankRange2: this.rankRange2 = v; break;
			case E_CDArenaRule.rankRange3: this.rankRange3 = v; break;
			case E_CDArenaRule.rankRange4: this.rankRange4 = v; break;
			case E_CDArenaRule.rankRange5: this.rankRange5 = v; break;
			case E_CDArenaRule.rankRange6: this.rankRange6 = v; break;
			case E_CDArenaRule.rankRange7: this.rankRange7 = v; break;
			case E_CDArenaRule.rankRange8: this.rankRange8 = v; break;
			case E_CDArenaRule.rankRange9: this.rankRange9 = v; break;
			case E_CDArenaRule.rankRange10: this.rankRange10 = v; break;
		}
	}


	/**数据*/
	public static datas: HashMap<number, CDArenaRule> = new HashMap<number, CDArenaRule>();



	/**加载数据*/
	public static load(byte: Byte): void{
		const size = byte.readInt32();
		const list : CDArenaRule[] = [];
		let i :number;

		for (i = 0; i < size; i++) {
			list[i] = new CDArenaRule();
		}
		for (i = 0; i < size; i++) {
			list[i].id = byte.readInt32();
			this.datas.put(list[i].id, list[i]);
		}
		for (i = 0; i < size; i++) {
			list[i].score = byte.readInt32();
		}
		for (i = 0; i < size; i++) {
			list[i].rankRange1 = byte.readInt32();
		}
		for (i = 0; i < size; i++) {
			list[i].rankRange2 = byte.readInt32();
		}
		for (i = 0; i < size; i++) {
			list[i].rankRange3 = byte.readInt32();
		}
		for (i = 0; i < size; i++) {
			list[i].rankRange4 = byte.readInt32();
		}
		for (i = 0; i < size; i++) {
			list[i].rankRange5 = byte.readInt32();
		}
		for (i = 0; i < size; i++) {
			list[i].rankRange6 = byte.readInt32();
		}
		for (i = 0; i < size; i++) {
			list[i].rankRange7 = byte.readInt32();
		}
		for (i = 0; i < size; i++) {
			list[i].rankRange8 = byte.readInt32();
		}
		for (i = 0; i < size; i++) {
			list[i].rankRange9 = byte.readInt32();
		}
		for (i = 0; i < size; i++) {
			list[i].rankRange10 = byte.readInt32();
		}
	}


	/** 获取数据*/
	public static getData(id: number): CDArenaRule{
		return this.datas ? this.datas.get(id) : null;
	}
}
